package com.thyme.controller;

import com.thyme.util.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author thyme
 * @ClassName TestController
 * @Description TODO
 * @Date 2020/4/25 11:13
 */
@RestController
@Slf4j
public class TestController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/sendMessage")
    public String sendMessage(@RequestParam("msg") String msg){
        log.info("发送的消息为："+ msg);
        rabbitTemplate.convertAndSend(Constants.DIRECT_MODE_QUEUE_ONE,msg);
        return "ok";
    }
}
